<?php

namespace Frieza\Modules\Link\Apis;

use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use Doraemon\tools\LinkFormat as formatServer;


class Linkformat extends Controller
{
    public function index(Request $request)
    {
        $request = $request->all();
        $linkType = $request['link_type'] ? : '';
        $linkParams = $request['link_params'] ? : '';

        if(empty($linkType)){
            return response()->json([
                'code' => 0,
                'msg' => '参数错误'
            ]);
        }

        $appLink = formatServer::generateLink($linkType, $linkParams);

        return response()->json([
            'code' => 1,
            'data'  => $appLink
        ]);
    }
}